const cheerio = require('../../../node_modules/cheerio');

async function getPuTongHua(idCard, name) {
    var [err, res] = await uni.request({
        url: 'http://shanxi.cltt.org/Web/Login/PSCP01001.aspx',
        header: {
            'Content-Type': 'application/x-www-form-urlencoded'
        },
        method: 'POST',
        data: "txtStuID=&txtCertificateNO=&txtCardNO=&__VIEWSTATE=&txtIDCard=" + idCard +
            "&btnLogin=%E6%9F%A5++%E8%AF%A2&txtName=" + name
    });

    if (err) return null

    console.log(res)

    let $ = cheerio.load(res.data);

    let ans = []
    for (let i = 2; i <= 6; i++) {
        for (let j = 2; j <= 4; j += 2) {
            $('#LooUpSocreList_Div > center > table > tr:nth-child(' + i + ') > td:nth-child(' + j + ')').each((idx,
            ele) => {
                // console.log(ele)
                let temp = $(ele).text() // 获取新闻标题
                temp = temp.trim()
                console.log(temp)
                ans.push(temp)
            });
        }
    }

    return ans

}

export {
    getPuTongHua
}
